package org.example.service;

import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

@LocalTCC
public interface IResultTccAction {

    /**
     * tcc try准备方法
     * @param businessActionContext 事务的上下文对象。可以在commit和cancel方法中传递参数
     * @param id
     * @param resultScore
     * @return
     */
    @TwoPhaseBusinessAction(name = "resultAction", commitMethod = "commit", rollbackMethod = "rollback")
    boolean prepare(BusinessActionContext businessActionContext,
                        @BusinessActionContextParameter(paramName = "resultId") int id,
                        @BusinessActionContextParameter(paramName = "resultScore") int resultScore);

    /**
     * tcc commit提交方法
     * @param businessActionContext
     * @return
     */
    boolean commit(BusinessActionContext businessActionContext);

    /**
     * tcc cancel回滚补偿方法
     * @param businessActionContext
     * @return
     */
    boolean rollback(BusinessActionContext businessActionContext);
}
